package com.oocl.products.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.oocl.products.dao.StoreDao;
import com.oocl.products.pojo.Store;
import com.oocl.products.util.DBHelper;

public class StoreDaoImpl implements StoreDao {
	public List<Store> queryAllStore() {
		Connection conn = DBHelper.getConnectionWithDs();
		List<Store> list = new ArrayList<Store>();
		Store store = null;
		String sql = "select * from store";
		PreparedStatement pst = null;
		ResultSet rst = null;
		try {
			pst =  conn.prepareStatement(sql);
			rst = pst.executeQuery();
		
			while(rst.next()){
				store = new Store();
				store.setSid(rst.getInt(1));
				store.setAddress(rst.getString(2));
				list.add(store);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DBHelper.close(pst, rst, conn);
		}
		return list;
	}

}
